const http=require('http')
const fs=require('fs')
const path=require('path')
var filePath=path.join(__dirname,'/data.json')
var fileContent=''
var fileData
fs.readFile(filePath,(err,data)=>{
    if(err){
        console.log(err)
    }else{
        fileContent+=data
        fileData=JSON.parse(fileContent)
        
    }
})

http.createServer((req,res)=>{
    var str=''
    req.on('data',(chunk)=>{
        str+=chunk
    })
    req.on('end',()=>{
        var obj=JSON.parse(str)
        var str1=fileData.userList+''
        var str2=obj+''
        if(str1.indexOf(str2)>=0){
            console.log('登录成功')
        }else{
            console.log('登录失败')
        }
    })
}).listen(8081)